package org.example.sportdemo.service;

import org.example.sportdemo.entity.Product;
import org.example.sportdemo.entity.ProductCollection;
import org.example.sportdemo.entity.Yonghu;
import org.example.sportdemo.mapper.ProductMapper;
import org.example.sportdemo.mapper.YonghuMapper;
import org.example.sportdemo.utils.PageUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;
import java.util.Map;

@Service
public class YonghuService {

    @Autowired
    private YonghuMapper yonghuMapper;

    public List<Yonghu> selectAll(){
        return yonghuMapper.selectAll();
    }

    public PageUtils queryPage(Map<String, Object> params) {
        //总数据
        List<Yonghu> groundList = yonghuMapper.selectAll();
        //总条数
        Integer totalCount = yonghuMapper.selectCount();
        //当前页
        Integer currPage = Integer.valueOf((String) params.get("currPage"));
        //每页条数
        Integer pageSize = Integer.valueOf((String) params.get("pageSize"));
        return new PageUtils(totalCount,(Integer) pageSize,currPage,groundList);
    }

    public void addYonghu(Yonghu yonghu) {

        yonghu.setBalance(0.0);
        yonghuMapper.addYonghu(yonghu);

    }

    public Yonghu selectById(Integer id) {
        return yonghuMapper.selectById(id);
    }

    public void updateYonghu(Yonghu yonghu) {
        yonghuMapper.updateYonghu(yonghu);
    }

    public void deleteByIds(Integer[] ids) {
        yonghuMapper.deleteByIds(ids);
    }

}
